package com.itheima.blog.admin.controller;


import com.itheima.api.client.blogAdminReport.ReportFeignClient;
import com.itheima.api.client.blogAdminReport.ReportVO;
import com.itheima.blog.admin.aop.MyLog;
import com.itheima.blog.admin.service.ReportService;
import com.itheima.common.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/report")
@Api(tags = "首页展示接口")
@RequiredArgsConstructor
public class ReportController {

    private final ReportService reportService;
    private final ReportFeignClient reportFeignClient;

    @GetMapping("/summary")
    @ApiOperation("首页文章和评论总数展示")
    public R fingLogAndCommentNumber() {
        return R.ok(reportFeignClient.fingLogAndCommentNumber());
    }

    @GetMapping("/category/blogs")
    @ApiOperation("每个分类的文章数")
    public R classificationNumber() {
        return R.ok(reportService.classificationNumber());
    }

    @GetMapping("/tag/blogs")
    @ApiOperation("每个标签的文章数")
    public R labelNumber() {
        return R.ok(reportFeignClient.labelNumber());
    }

    @GetMapping("/province/blogs/{type}")
    @ApiOperation("每个省份发博客数量(地图)")
    public R provinceBlogs(@PathVariable("type") Integer type) {
        List<ReportVO> reportVOS = reportFeignClient.provinceBlogs(type);
        return R.ok(reportVOS);
    }

    @GetMapping("/contribute")
    @ApiOperation("文章贡献度")
    public R contributeForLastYear() {
        return R.ok(reportFeignClient.contributeForLastYear());
    }
}
